package com.rongmai.db.model;

import java.util.Map;

/**
 * @ClassName PaginationParam
 * @Description 分页参数
 *
 * @author sunhaojie 3113751575@qq.com
 * @date 2016年12月7日 下午11:33:40
 */
public class PaginationParam extends BaseParam {

    private static final long serialVersionUID = 5696393468448500428L;
    
    /**
	 * 页号
	 */
	private int page = 1;
	/**
	 * 容量
	 */
	private int size = 10;

    /**
     * 偏移量
     */
    private int offset = 0;

    public PaginationParam() {

	}

	/**
	 * @param page
	 * @param size
	 */
	public PaginationParam(int page, int size) {
		super();
		this.page = page;
		this.size = size;
	}

	/**
	 * @return the page
	 */
	public int getPage() {
		return page;
	}

	/**
	 * @param page
	 *            the page to set
	 */
	public void setPage(int page) {
		this.page = page;
	}

	/**
	 * @return the size
	 */
	public int getSize() {
		return size;
	}

	/**
	 * @param size
	 *            the size to set
	 */
	public void setSize(int size) {
		this.size = size;
	}

	/**
	 * 
	 * @Title getOffset
	 * @Description 获取偏移量
	 * @return
	 *
	 * @author sunhaojie 3113751575@qq.com
	 * @date 2017年2月8日 下午10:57:02
	 */
	public int getOffset() {
		int page = this.page;
		if (page <= 0) {
			page = 1;
		}
		this.offset = (page - 1) * size;
		return this.offset;
	}


	/*
	 * (non-Javadoc)
	 * 
	 * @see com.posjiajia.commom.utils.vo.param.BaseParam#getParamMap()
	 */
	@Override
	public Map<String, Object> getParamMap() {
		Map<String, Object> paramMap = super.getParamMap();
		paramMap.put("page", page);
		paramMap.put("size", size);
		return paramMap;
	}

    public void setOffset(int offset) {
        this.offset = offset;
    }
}
